/**********************************************
 * 	TestPreposition.java					  *
 *  Course: CS3343							  *
 *  Version: 2.5    Release 3				  *
 *  Last Modified : 22 MAR 2013			      *
 **********************************************/
package testChecker;


import org.junit.Before;
import junit.framework.TestCase;
import checker.Preposition;

import org.junit.Test;


public class TestPreposition extends TestCase{

     
	@Before
	public void setUp() throws Exception {

	}
	
	//unit test that checks
	@Test
	public void testPrepositionA(){
		
		class PrepositionStub extends Preposition{
			public  boolean isOfType(String word){
				//get all the words starting with the letter that is the same as the initial letter of the input word
				//the second argument is the type of words to be retrieved for comparison, in this case, prepositions
				//the return value is an array containing all the relevant words
				String[] prepositions = {"on", "in","above", "upon",  "onto", "via" };
				
				//simply compare each value in the array with the input word
				for(int i = 0; i < prepositions.length; i++){
					if(prepositions[i].equalsIgnoreCase(word))
						//returning true means this is a preposition
						return true;
				}
				return false;
			}
		
		};
		
		PrepositionStub prepositionStub = new PrepositionStub();
		
		boolean result = prepositionStub.isOfType("above");
		assertEquals(true, result);
		
	}

	//Test initial letter A
	@Test
	public void testPrepositionB(){
		
		class PrepositionStub extends Preposition{
			public  boolean isOfType(String word){
				//get all the words starting with the letter that is the same as the initial letter of the input word
				//the second argument is the type of words to be retrieved for comparison, in this case, prepositions
				//the return value is an array containing all the relevant words
				String[] prepositions = {"on", "in","above", "upon",  "onto", "via" };
				
				//simply compare each value in the array with the input word
				for(int i = 0; i < prepositions.length; i++){
					if(prepositions[i].equalsIgnoreCase(word))
						//returning true means this is a preposition
						return true;
				}
				return false;
			}
		
		};
		
		PrepositionStub prepositionStub = new PrepositionStub();
		
		boolean result = prepositionStub.isOfType("to");
		assertEquals(false, result);
		
	}

	//integration test 1 with the FileIO class
	@Test
	public void testIntegrationWithFileIO1(){
	    Preposition preposition = new Preposition();
		boolean result = preposition.isOfType("aboard");
		assertEquals(true, result);
	
	}
	
	//integration test 2 with the FileIO class
	@Test
	public void testIntegrationWithFileIO2(){
	    Preposition preposition = new Preposition();
		boolean result = preposition.isOfType("fast");
		assertEquals(false, result);
		
	}
	
	//integration test 3 with the FileIO class
	@Test
	public void testIntegrationWithFileIO3(){
	    Preposition preposition = new Preposition();
		boolean result = preposition.isOfType("behind");
		assertEquals(true, result);
	
	}
	
	//integration test 4 with the FileIO class
	@Test
	public void testIntegrationWithFileIO4(){
	    Preposition preposition = new Preposition();
		boolean result = preposition.isOfType("sad");
		assertEquals(false, result);
		
	}
	
	//integration test 5 with the FileIO class
	@Test
	public void testIntegrationWithFileIO5(){
	    Preposition preposition = new Preposition();
		boolean result = preposition.isOfType("down");
		assertEquals(true, result);
	
	}
	
	//integration test 6 with the FileIO class
	@Test
	public void testIntegrationWithFileIO6(){
	    Preposition preposition = new Preposition();
		boolean result = preposition.isOfType("the");
		assertEquals(false, result);
		
	}
	//test user-defined constructor
	@Test
	public void testUserDefinedConstructor(){
		Preposition preposition  = new Preposition("[pre]");
		String result = preposition.getSign();
		assertEquals("[pre]", result);
		
	}

}
